<?php
namespace app\common\model;

use think\Model;

class PayBis extends BaseModel {
    // 创建[畅远]签名
    // $isDaifu代付时为true，否则为false
    public function createSign($list, $isDaifu) {
        ksort($list);
        $md5str = '';
        foreach ($list as $key => $val) {
            if(!empty($val)){
                $md5str = $md5str . $key . '=' . $val . '&';
            }
        }

        if($isDaifu) {
            // 如果是代付
            $ret = $this->get(['id'=>$list['memberid']]);
            $md5key = $ret ->daifumd5key;
        } else {
            $ret = $this->get(['id'=>$list['pay_memberid']]);
            $md5key = $ret ->md5key;
        }
        $sign = strtoupper(md5($md5str . 'key=' . $md5key));
        return $sign;
    }
}